﻿using System.Windows.Controls;
using Microsoft.Kinect;
using Coding4Fun.Kinect.Wpf;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System;


namespace KinectControls
{
    /// <summary>
    /// Interaction logic for HandCursor.xaml
    /// </summary>
    public partial class HandCursor : UserControl
    {
        public HandCursor()
        {
            InitializeComponent();
        }

        public void SetPosition(Joint joint)
        {
            /* Joint should get scaled but do not have correct dll */
            Joint scaledJoint = joint;//.ScaleTo(800, 600, 0.5f, 0.5f);
            
            Canvas.SetLeft(this, scaledJoint.Position.X);
            Canvas.SetTop(this, scaledJoint.Position.Y);
        }

        // Set the image of the HandCursor to represent a black left hand
        public void SetLeftBlack()
        {
            ImageBrush leftHand = new ImageBrush();
            leftHand.ImageSource = new BitmapImage(new Uri("pack://application:,,,/KinectControls;component/Images/Hand-flipped-black.png"));

            hand.Fill = leftHand; 
        }

        // Set the image of the HandCursor to represent a white left hand
        public void SetLeftWhite()
        {
            ImageBrush leftHand = new ImageBrush();
            leftHand.ImageSource = new BitmapImage(new Uri("pack://application:,,,/KinectControls;component/Images/Hand-flipped.png"));

            hand.Fill = leftHand;
        }

        // Set the image of the HandCursor to represent a black right hand
        public void SetRightBlack()
        {
            ImageBrush rightHand = new ImageBrush();
            rightHand.ImageSource = new BitmapImage(new Uri("pack://application:,,,/KinectControls;component/Images/Hand-black.png"));

            hand.Fill = rightHand;
        }

        // Set the image of the HandCursor to represent a white right hand
        public void SetRightWhite()
        {
            ImageBrush rightHand = new ImageBrush();
            rightHand.ImageSource = new BitmapImage(new Uri("pack://application:,,,/KinectControls;component/Images/Hand.png"));

            hand.Fill = rightHand;
        }
    }
}
